package ut

import (
	"golang.org/x/exp/rand"
	"time"
)

func GetOrDefault(value, def string) string {
	if len(value) == 0 {
		return def
	}
	return value
}

func Contains[T int | string](data []T, value T) bool {
	for _, v := range data {
		if v == value {
			return true
		}
	}
	return false
}

// Rand 随机数生成
func Rand(n int) int {
	rand.New(rand.NewSource(uint64(time.Now().UnixNano())))
	return rand.Intn(n)
}
